<template>
	<view>
		<wanl-empty text="没有找到团队" v-if="data == 0"></wanl-empty>
		<view class="" v-else>
			<view class="edgeInsetTop"></view>
			<view class="wanl-goods-comment">
				<!-- <wanl-empty text="没有找到团队列表" v-if="listData.length == 0"></wanl-empty> -->

				<block v-for="(item, index) in data" :key="index">
					<view class="lsit">
						<view class="image" v-if="item.avatar"><image :src="item.avatar" mode=""></image></view>
						<view class="image" v-else></view>
						<text>{{ item.username }}</text>
					</view>
				</block>
				<uni-load-more :status="status" :content-text="contentText" />
			</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	computed: { ...mapState(['user']) },
	data() {
		return {
			data: [],
			listData: [], //列表
			reload: false, //判断是否上拉
			current_page: 1, //当前页码
			last_page: 1, //总页码
			status: 'loading',
			page: 1,
			pagesize: 10,
			contentText: {
				contentdown: ' ',
				contentrefresh: '加载中',
				contentnomore: '',
			},
		};
	},
	onLoad(option) {
		this.loadData();
		this.team();
	},
	onPullDownRefresh() {
		this.current_page = 1;
		this.reload = true;
		this.loadData();
	},
	onReachBottom() {
		// 判断是否最后一页
		if (this.current_page >= this.last_page) {
			this.status = 'noMore';
		} else {
			this.reload = false;
			this.current_page = this.current_page + 1; //页码+1
			this.status = 'loading';
			this.loadData();
		}
	},
	methods: {
		// wanlshop/dshapi/my_team
		async team() {
			this.$api.get({
				url: '/wanlshop/dshapi/my_team',
				data: {
					page: 1,
					pagesize: 10,
				},
				success: res => {
					console.log('res ++++++++++++++++++++++++++++++++ >> ', res);
				},
			});
			//this.data = res;
		},

		async loadData() {
			// 加载商品
			this.$api.get({
				url: '/wanlshop/user/comment',
				data: {
					page: this.current_page,
				},
				success: res => {
					uni.stopPullDownRefresh();
					this.listData = this.reload ? res.data : this.listData.concat(res.data); //评论数据 追加
					this.current_page = res.current_page; //当前页码
					this.last_page = res.last_page; //总页码
					this.status = res.total == 0 ? 'noMore' : 'more';
				},
			});
		},
		// 预览图片
		previewImage(image, index) {
			var imgArr = [];
			for (var item of image) {
				imgArr = imgArr.concat(this.$wanlshop.oss(item, 500));
			}
			uni.previewImage({
				urls: imgArr,
				current: imgArr[index],
				indicator: 'number',
			});
		},
	},
};
</script>

<style lang="scss" scoped>
.lsit {
	width: 690rpx;
	height: 100rpx;
	background: #ffffff;
	border-radius: 10rpx;
	
	margin: 30rpx auto;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	.image {
		width: 80rpx;
		height: 80rpx;
		background: #eeca86;
		border-radius: 50%;
		margin-left: 21rpx;
	}
	text {
		margin-left: 21rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}
}
</style>
